<?php
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.controller' );
class ComplaintsControllercomment extends JController {
	function __construct() {
		if(JRequest::getCmd('view') == '') {
			JRequest::setVar('view', 'default');
		}
		$this->item_type = 'Default';
		parent::__construct();
		$this->registerTask('addcomment', 'editcomment');
	}
	function editcomment() {
		JRequest::setVar('view', 'editcomment');
		JRequest::setVar('hidemainmenu', 1);
		$model = $this->getModel('comment');
		$user =& JFactory::getUser();
		parent::display();
	}
	function save() {
		$model = $this->getModel('comment');
		if ($model->store()) {
			$msg = JText::_('com_complaints_comment_SAVED');
		} else {
			$msg = JText::_('com_complaints_comment_ERROR_SAVED');
		}
		$link 	= 'index.php?option=com_complaints&view=comment';
		$this->setRedirect($link, $msg);
	}
	function delete() {
		$model = $this->getModel('comment');
		$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
		if (!is_array($cid) || count($cid) < 1) {
			$msg = '';
			JError::raiseWarning(500, JText::_( 'com_complaints_SELECT_DELETE' ) );
		} else {
			foreach ($cid as $id) {
			if (!$model->delete($id)) {
				JError::raiseError(500, JText::_('com_complaints_DELETE_FAILED').'<pre>'.print_r($cid, true).'</pre>');
			}
		}
		$msg = count($cid).' '.JText::_( 'com_complaints_SELECTED_DELETE' );
		$cache = &JFactory::getCache('com_complaints');
		$cache->clean();
		}
		$this->setRedirect( 'index.php?option=com_complaints&view=comment', $msg );
		}
	}
?>
